/**
 * Created by Sean on 2017/5/9.
 */


class Thread2 implements Runnable {

    private String threadName;

    public Thread2(String threadName) {
        this.threadName = threadName;
    }

    @Override
    public void run() {
        for (int i = 0; i < 5; i++) {
            System.out.println(threadName + "运行，此时的 i = " + i);
            try {
                Thread.sleep((int) Math.random() * 10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

public class Main2 {
    public static void main(String[] args) {
        new Thread(new Thread2("我是在A线程中")).start();
        new Thread(new Thread2("我是在B线程中")).start();
    }
}
